﻿using System;
using System.Data;
using System.Web.UI;

namespace GridView的使用
{
    public partial class StudentDetails : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string studentID = Request.QueryString["id"];

            if (!Page.IsPostBack)
            {
                ShowData(studentID);
            }
        }

        private void ShowData(string studentID)
        {
            string commandText = String.Format("SELECT * FROM Student WHERE StudentID='{0}'", studentID);
            DataSet dataSet = SqlHelper.GetDataSetBySqlCommand(commandText, SqlHelper.GetConnection());
            DetailsView1.DataSource = dataSet;
            DetailsView1.DataBind();
        }
    }
}